const webpack = require('webpack');
// import webpack from 'webpack';
const plugins = require('webpack-load-plugins')();

// var commonsPlugin = new webpack.optimize.CommonsChunkPluginn('common.js');

const copyRight = `copy right 
@ sync`;

module.exports = {
    entry: {
        index: './src/js/index.jsx'
        //   'aa': './src/css/style.css'
    },

    // entry: './src/js/main.jsx',

    output: {
        path: './build',
        filename: 'bundle.js',
        // publicPath: '/asset/'
    },

    module: {
        loaders: [
            // {
            //   test: /\.css$/,
            //   loader: 'style!css'
            // },
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['es2015', 'react']
                }
            },
            {
                test: /\.css$/,
                loader: plugins.extractText.extract('style-loader', 'css-loader!postcss-loader')
            }
        ]
    },

    plugins: [
        // new webpack.optimize.UglifyJsPlugin({
        //     compress: {
        //         warnings: false
        //     }
        // }),
        new webpack.BannerPlugin(copyRight),
        // new plugins.html({
        //   title: 'dev-index',
        //   filename: 'index.html'
        // }),
        new plugins.extractText('[name].css', {allChunks: true})
    ],

    resolve: {
        extensions: ['', '.js', '.css', '.scss', '.jsx', '.png', '.jpg']
    }
};
